package com.atguigu.juc.locks;

import java.util.concurrent.TimeUnit;

//两部手机,两个静态同步方法
class Phone6{
    public static synchronized void sengEmail(){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "正在发邮件...");
    }
    public static synchronized void sengSMS(){
        System.out.println(Thread.currentThread().getName() + "正在发短信...");
    }
}

public class Lock8_6 {
    public static void main(String[] args) {
        Phone6 phone6 = new Phone6();
        Phone6 phone6_2 = new Phone6();

        new Thread(()->{phone6.sengEmail();},"t1").start();

        try {
            TimeUnit.MILLISECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{phone6_2.sengSMS();},"t2").start();
    }
}
